package com.autumn.zero.workflow.services;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;

import org.activiti.engine.delegate.DelegateExecution;
import org.activiti.engine.delegate.DelegateTask;

import com.autumn.zero.workflow.entitys.AbstractWorkflowProcess;
import com.autumn.zero.workflow.entitys.WorkflowUserTaskComplete;
import com.autumn.zero.workflow.entitys.WorkflowUserTaskWait;
import com.autumn.zero.workflow.values.ProcessStartValue;
import com.autumn.zero.workflow.values.ProcessTaskCompleteValue;

/**
 * 进程服务抽象
 * 
 * @author 杨昌国 2019-01-15 14:43:17
 */
public interface IProcessService {

	/**
	 * 启动流程事件
	 * 
	 * @param value 值
	 */
	void startProcess(ProcessStartValue value);

	/**
	 * 启动流程保存
	 * 
	 * @param execution 执行
	 * @return
	 */
	AbstractWorkflowProcess startProcessEventSave(DelegateExecution execution);

	/**
	 * 结束流程保存
	 * 
	 * @param execution 执行
	 * @return
	 */
	void endProcessEventSave(DelegateExecution execution);

	/**
	 * 用户待办任务事件
	 * 
	 * @param delegateTask
	 * @return
	 */
	WorkflowUserTaskWait userTaskWaitEvent(DelegateTask delegateTask);

	/**
	 * 用户完成任务事件
	 * 
	 * @param delegateTask
	 * @return
	 */
	WorkflowUserTaskComplete userTaskCompleteEvent(DelegateTask delegateTask);

	/**
	 * 用户删除任务事件
	 * 
	 * @param delegateTask
	 * @return
	 */
	void userTaskDeleteEvent(DelegateTask delegateTask);

	/**
	 * 任务完成
	 * 
	 * @param value 值
	 */
	void taskComplete(ProcessTaskCompleteValue value);

	/**
	 * 根据流程图实例写入流程图
	 * 
	 * @param processInstanceId 流程图实例id
	 * @param outputStream      输出流
	 */
	void writeFlowImageByInstanceId(String processInstanceId, OutputStream outputStream) throws IOException;

	/**
	 * 查询流程图片
	 * 
	 * @param processInstanceId 流程图实例id
	 * @return
	 * @throws IOException
	 */
	InputStream queryFlowImageByInstanceId(String processInstanceId) throws IOException;

	/**
	 * 查询流程进程实例
	 * 
	 * @param id 流程id
	 * @return
	 */
	AbstractWorkflowProcess queryWorkflowProcessById(Long id);

	/**
	 * 查询流程进程实例
	 * 
	 * @param processInstanceId 流程实例id
	 * @return
	 */
	AbstractWorkflowProcess queryWorkflowProcessByInstanceId(String processInstanceId);
}
